// https://leetcode-cn.com/problems/projection-area-of-3d-shapes/
#include <vector>
#include <iostream>

using namespace std;

class Solution {
public:
    int projectionArea(vector<vector<int>>& grid) {
		int xy = 0; // 所有元素的个数,且当前元素的值不能为0
		int xz = 0; // 每个组中单个元素所在y轴中的最大值
		int yz = 0; // 每个组中单个元素所在x轴中的最大值
		int len = grid.size();
		for(int i = 0; i < len; i++){
			int maxYzHeight = 0;
			int maxXzHeight = 0;
			for(int j = 0; j < len; j++){
				xy += grid[i][j] > 0 ? 1 : 0;
				maxXzHeight = max(maxXzHeight, grid[i][j]);
				maxYzHeight = max(maxYzHeight, grid[j][i]);
			}
			xz += maxXzHeight;
			yz += maxYzHeight;
		}
		return xy + xz + yz;
    }
};

int main(){
	vector<vector<int>> nums = {{1,2},{3,4}};
	Solution so;
	int area = so->projectionArea(nums);
	cout << "area:" << area << endl;
}